home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagd_f.zip / DRIVES.SWG / 0028_Get Device Type.pas < prev    next >
Pascal/Delphi Source File  |  1993-08-18  |  2KB  |  64 lines

  1. { Gets the device type.
  2.   Part of the Heartware Toolkit v2.00 (HTdisk.PAS) for Turbo Pascal.
  3.   Author: Jose Almeida. P.O.Box 4185. 1504 Lisboa Codex. Portugal.
  4.           I can also be reached at RIME network, site ->TIB or #5314.
  5.   Feel completely free to use this source code in any way you want, and, if
  6.   you do, please don't forget to mention my name, and, give me and Swag the
  7.   proper credits. }
  8.  
  9. PROCEDURE dpDevType(Drive : byte;
  10.           var Device_Type : byte;
  11.            var Error_Code : byte);
  12.  
  13. { DESCRIPTION:
  14.     Gets the device type.
  15.   SAMPLE CALL:
  16.     dpDevType(1,Device_Type,Error_Code);
  17.   ON ENTRY:
  18.     Drive:
  19.       1 : drive A:
  20.       2 : drive B:
  21.       and so on...
  22.   RETURNS:
  23.     Device_Type :
  24.       0 : 320/360 KBytes floppy
  25.       1 : 1.2 MBytes floppy
  26.       2 : 720 KBytes floppy
  27.       3 : 8" single density floppy
  28.       4 : 8" double density floppy
  29.       5 : hard disk
  30.       6 : tape drive
  31.       7 : 1.44 MBytes floppy
  32.       8 : read/write optiocal disk
  33.       9 : 2.88 MBytes floppy
  34.       else : unknown device type
  35.     Error_Code:
  36.       0 : no error
  37.       else : error number (see The PC Programmers Source Book 3.191)
  38.   NOTES:
  39.     Applies to all DOS versions beginning with v3.3.
  40.     See dpDevType_Text() in order to get a string text. }
  41.  
  42. var
  43.   TmpA   : array[0..31] of byte;
  44.   HTregs : registers;
  45.  
  46. BEGIN { dpDevType }
  47.   HTregs.AX := $440D;
  48.   HTregs.BX := word(Drive);
  49.   HTregs.CX := $0860;
  50.   HTregs.DX := Ofs(TmpA);
  51.   HTregs.DS := Seg(TmpA);
  52.   MsDos(HTregs);
  53.   if HTregs.Flags and FCarry <> 0 then
  54.     begin
  55.       Device_Type := $FF;          { on error returns unknown device type }
  56.       Error_Code := HTregs.AL
  57.     end
  58.   else
  59.     begin
  60.       Device_Type := TmpA[1];
  61.       Error_Code := 0;
  62.     end;
  63. END; { dpDevType }
  64.